package com.xgimi.open.skill.datamanager.biz.common.exception;

import com.xgimi.open.skill.datamanager.biz.common.Enum.ExceptionErrorCode;

/**
 * @author coderzpw.zhang
 * @version 1.0
 * @description 自定义异常
 * @date 2023/2/3 15:02
 */
public class BaseException extends RuntimeException {


    private static final long serialVersionUID = -5165894053466746828L;
    /**
     * 错误码
     */
    private final int code;

    /**
     * 错误信息
     */
    protected String message;

    public BaseException() {
        this.code = ExceptionErrorCode.UN_KNOW_ERROR.getCode();
        this.message = ExceptionErrorCode.UN_KNOW_ERROR.getMessage();
    }

    public BaseException(int code) {
        this.code = code;
        this.message = ExceptionErrorCode.UN_KNOW_ERROR.getMessage();
    }

    public BaseException(String message) {
        this.code = ExceptionErrorCode.UN_KNOW_ERROR.getCode();
        this.message = message;
    }

    public BaseException(int code, String message) {
        this.code = code;
        this.message = message;
    }

    public int getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }
}
